package com.example.comm.activity;

import android.content.Intent;
import android.os.Bundle;

import androidx.annotation.Nullable;
import androidx.appcompat.app.AppCompatActivity;

import com.example.comm.Bean.User;
import com.example.comm.MainActivity;
import com.example.comm.R;

import java.sql.Time;
import java.util.Timer;
import java.util.TimerTask;

import cn.bmob.v3.Bmob;
import cn.bmob.v3.BmobUser;
import cn.bmob.v3.http.I;

public class Splash extends AppCompatActivity {
    @Override
    protected void onCreate(@Nullable Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);
        setContentView(R.layout.activity_splash);//用来关联布局文件
        //演示操作
        Timer timer = new Timer();
        timer.schedule(timetast, 2000);
        Bmob.initialize(this, "bf3767bf4ff13d8b86eca605eb177e0a");

    }


        TimerTask timetast=new TimerTask() {
            @Override
            public void run() {
               // startActivity(new Intent(Splash.this, MainActivity.class));
                //登录了就挑战主界面 没登陆就跳登陆界面
                BmobUser bmobUser=BmobUser.getCurrentUser(User.class);
                if(bmobUser!=null){
                    startActivity(new Intent(Splash.this,MainActivity.class));
                    finish();
                }else{
                    //没有登陆
                    startActivity(new Intent(Splash.this,Login.class));
                    finish();
                }
            }
        };

}
